<?php
	class Model_books extends CI_Model{
	function __construct()
	{
			parent::__construct();
		$this->load->database();
	}
	function listbooks()
	{
		$this->db->order_by('id','desc');
		$this->db->limit('10');
		$query=$this->db->get('products');
		if($query->num_rows() > 0)
		{
			foreach($query->result_array() as $item)
			{
				$data[]=$item;
			}
			return $data;
		}		
	}
	function getbooks($id)
	{
		$this->db->where('id',$id);
		$query=$this->db->get('products');
		$row=$query->row_array();

		return $row;
	}	
}